home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
TPUG - Toronto PET Users Group
/
TPUG Users Group CD
/
TPUG Users Group CD.iso
/
AMIGA
/
AMICUS
/
AMICUS04.ADF
/
C
/
addmem.c
next >
Wrap
C/C++ Source or Header
|
1985-10-30
|
5KB
|
200 lines
/*************** READ.ME *************************/
If you have a 512K memory board hanging off the side of your Amiga
the following describes a way of
adding memory which is not done from an auto-configured memory board.
addmem_cmd.ld will give this memory to the exec to use.
This program takes two parameters, the starting and ending addresses
in hex of memory to add. For instance to add all of the ramcart:
addmem f00000 f7ffff
Caveat Empour:
Our software should support extra non-display memory, BUT this
has hardly been tested at all. If you find problems, PLEASE
REPORT them!
One already known bug, is you can't switch disks when you have
the extra memory (in V27.5). Don't even think about doing a
diskcopy. However for the brave and daring,
you might create an EXECUTE file:
; V27 version of RAM: commands.
addmem f00000 f7ffff
makedir ram:c
run copy sys:c ram:c all
cd comdir ram:c
; V28 Version
addmem f00000 f7ffff
makedir ram:c
run copy sys:c ram:c all
; Remove the current reference.
assign c:
; Make a new reference.
sys:c/assign c: ram:c
This will make all your commands "load" much faster.
For those developing on an Amiga you might also want to put
amiga.lib and lc.lib in the RAM:.
More caveats are in order:
This region of memory is searched by exec on system reset.
If it finds something that it thinks it recognizes (as a library, for
example), it will attempt to run it. Power-off and on the ramcart to
clear its memory if you suspect this.
If the first two words of the memory are the right magic numbers,
kickstart will jump to this memory on reset.
Non-autoconfigurable memory is not supportable. It is fine to use
it for now -- we have no alternatives. However, you system may well
break once we get the expansion architecture in place.
/*************** Makefile ************************/
Amiga_VERS=../../../../
SUBSYSNAME=addmem
MAKEFILE=Makefile
STARTUP=$(Amiga_VERS)internal/lib/startup.obj
CFILES= addmem.c addmem_cmd.c
OFILES= addmem.obj addmem_cmd.obj
all: addmem.ld
.INCLUDE=$(Amiga_VERS)tools/makemeta
/*************** addmem.with *********************/
FROM *
../../../../internal/lib/startup.obj,*
addmem.obj,*
addmem_cmd.obj
LIBRARY *
/usr/commodore/amiga/V27/internal/lib/amiga.lib
/*************** addmem.c ************************/
/*
* addmem.c -- deallocate more memory for programs to use with
* the memory allocator.
* July 7, 1985 Version 1.0 Keith Stobie Original version
*
* Link startup.obj, addmem.obj and addmem_cmd.obj using amiga.lib
* to create addmem.ld.
*/
#include "exec/types.h"
#include "exec/exec.h"
#include "exec/execbase.h"
addmem (lower,upper)
long lower;
long upper;
{
struct ExecBase **SysBase = (struct ExecBase **) 4;
struct MemHeader *new_area;
new_area = (struct MemHeader *) AllocMem (sizeof (struct MemHeader),
MEMF_PUBLIC);
if (new_area == 0) {
printf ("%s: unable to allocate memory to MemHeader!\n");
exit (10);
}
new_area -> mh_Node.ln_Type = NT_MEMORY;
new_area -> mh_Attributes = MEMF_FAST | MEMF_PUBLIC;
new_area -> mh_Lower = (APTR) lower;
new_area -> mh_Upper = (APTR) upper;
new_area -> mh_Free = 0;
printf ("lower=0x%lx, upper=0x%lx, new_area=0x%lx\n", lower,
upper, new_area);
AddHead (&(*SysBase) -> MemList, new_area);
Deallocate (new_area, lower, (upper - lower));
}
/*************** addmem_cmd.c ********************/
/*
* addmem_cmd.c - CLI command to allow users to add memory by
* calling addmem().
* First version, Keith Stobie
* Revised version, Carl Sassenrath
* July 7, 1985 Version 1.0 Keith Stobie First public version.
*
*/
#define VERSION "1.0"
#include <exec/types.h>
#include <exec/exec.h>
#include <exec/execbase.h>
char *program_name;
print_usage()
{
printf( "%s: version %s\n", program_name, VERSION );
printf( "usage: %s <lower-hex-addr> <upper-hex-addr> \n", program_name );
exit( 5 );
}
main(argc,argv)
int argc;
char *argv[];
{
long lower,
upper;
program_name = *argv++;
if (argc == 1) print_usage();
if (argc < 3) {
printf( "%s: Missing upper address!\n", program_name );
print_usage();
}
lower = gethex (argv[0]);
upper = gethex (argv[1]);
addmem (lower, upper);
}
long gethex(s)
char *s;
{
long num = 0;
char ch;
while ((ch = *s++) != 0) {
switch (ch) {
case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9':
num = num * 16 + (ch - '0');
break;
case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
num = num * 16 + (ch - 'a') + 10;
break;
case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
num = num * 16 + (ch - 'A') + 10;
break;
default:
printf ("Non hex digit found '%lc'\n", ch);
print_usage ();
} /* switch */
}
return num;
} /* gethex */